<?php

/*

Process Create Auction (auctions_create.pro.php)

*/
ob_start();
include "global.inc.php";

$finditem = fetch("SELECT * FROM usersitems2 WHERE owner = '$userid' AND id = '$auction_item' AND game = '$game'");
if (!$finditem[id])
{
	die(header(error("auctions_create.php?game=$game","That item is not yours.")));
}
$finditem2 = fetch("SELECT * FROM items2 WHERE id = '$finditem[item_id]' AND game = '$game'");
if ($finditem[parts_left] != $finditem2[parts])
{
	die(header(error("auctions.php?game=$game","That item can not be auctioned, it has already been used!")));
}

if ($end_in > 172800) { $end_in = 172800; }

if ($min_increment > 50000) { $min_increment = 50000; }

if ($buy_now_price < 0) { $buy_now_price = 0; }

$endTime = $timestamp + $end_in;

mysql_query("INSERT INTO auctions2 (item_name,owner,high_bid,buy_now_price,end_time,min_increment,game) VALUES ('$finditem2[item_name]','$username','$start_price','$buy_now_price','$endTime','$min_increment','$game')");

mysql_query("DELETE FROM usersitems2 WHERE owner = '$userid' AND id = '$auction_item' AND game = '$game'");

die(header(error("auctions.php?game=$game&page=search&search_by=my_auctions","That item has been put into auction!")));
?>